import smtplib
from email.message import EmailMessage

# 18513117913@163.com
# Fleeting_Cen10
# smtp.163.com, 25

sender = '18513117913@163.com'
password = 'OROPBPZULYDMLGPZ'     # 授权码
to_you = '' # '2443362393@qq.com'
smtp = "smtp.163.com"
subject = '计算器的测试报告——唐浩然'   # 主题
body = '两位数的运算'                 # 正文

file=r'E:\BaiduNetdiskDownload\汉科软 实训软件\项目\hkr-thr\当前项目\day8\calc.html'#添加附件
atth=open(file, "rb").read()        #选择附件

#qq邮箱信息部分填充
message=EmailMessage()#引用emial信息数据
message['Subject']=subject
message['From']=sender
message['To']=to_you
message.set_content(body)#连接你的正文
message.add_attachment(atth, maintype='file',subtype='html',filename=file)  #添加附件

#启动邮箱的服务
server = smtplib.SMTP(smtp, port=25)
server.login(sender, password)
server.send_message(message)

server.quit()